﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.css.transitions {
    import reprise.css.*;
    import flash.utils.*;

    public class CSSPropertyTransition {

        protected var m_startValue:CSSProperty;
        public var delay:CSSProperty;
        protected var m_backupValue:CSSProperty;
        public var shortcut:String;
        public var hasCompleted:Boolean;
        public var currentRatio:Number;// = 0
        public var duration:CSSProperty;
        public var property:String;
        protected var m_propertyTransition:PropertyTransitionVO;
        public var easing:Function;
        protected var m_endValue:CSSProperty;
        public var currentValue:CSSProperty;
        protected var m_startTime:int;
        protected var m_lastUpdateTime:int;

        public function CSSPropertyTransition(_arg1:String, _arg2:String=null){
            property = _arg1;
            this.shortcut = _arg2;
            m_propertyTransition = TransitionVOFactory.transitionForPropertyName(_arg1);
        }
        public function setValueForTimeInContext(_arg1:int, _arg2:int, _arg3:Object):void{
            var _local4:int = (duration.valueOf() as int);
            var _local5:int = (delay) ? delay.specifiedValue() : 0;
            if ((_arg1 - m_lastUpdateTime) > _arg2){
                m_startTime = (m_startTime + ((_arg1 - m_lastUpdateTime) - _arg2));
            };
            m_lastUpdateTime = _arg1;
            var _local6:int = ((_arg1 - m_startTime) - _local5);
            if (_local6 < 0){
                return;
            };
            if (_local4 <= _local6){
                hasCompleted = true;
                currentValue = endValue;
                return;
            };
            currentRatio = easing(_local6, 0, 1, _local4);
            var _local7:CSSProperty = currentValue;
            currentValue = m_backupValue;
            m_backupValue = _local7;
            currentValue.setSpecifiedValue(m_propertyTransition.setCurrentValueToRatio(currentRatio));
        }
        public function updateValues(_arg1:CSSProperty, _arg2:CSSProperty, _arg3:CSSProperty, _arg4:int, _arg5:int, _arg6:Object):void{
            var _local11:int;
            var _local12:Number;
            var _local13:int;
            var _local14:Number;
            var _local15:int;
            var _local16:int;
            var _local7:CSSProperty = this.startValue;
            var _local8:CSSProperty = this.endValue;
            var _local9:CSSProperty = this.currentValue;
            var _local10:int = m_startTime;
            if ((_arg4 - m_lastUpdateTime) > _arg5){
                _local10 = (_local10 + ((_arg4 - m_lastUpdateTime) - _arg5));
            };
            this.endValue = _arg1;
            this.duration = _arg2;
            this.delay = _arg3;
            m_startTime = (m_lastUpdateTime = _arg4);
            if (_local7 == _arg1){
                this.startValue = _local8;
                _local11 = (_arg2.valueOf() as int);
                _local12 = (1 - currentRatio);
                _local13 = 0;
                _local14 = 0;
                while (_local14 < _local12) {
                    _local13 = (_local13 + 5);
                    _local14 = easing(_local13, 0, 1, _local11);
                };
                this.m_startTime = (this.m_startTime - (_local13 + (_arg3) ? _arg3.specifiedValue() : 0));
            } else {
                this.startValue = _local9;
                if (currentRatio == 0){
                    _local15 = (getTimer() - _local10);
                    _local16 = (_arg3) ? _arg3.specifiedValue() : 0;
                    if (_local16 > _local15){
                        this.m_startTime = (this.m_startTime - _local15);
                    } else {
                        this.m_startTime = (this.m_startTime - _local16);
                    };
                    this.m_startTime = (this.m_startTime - (_local15 - _local16));
                } else {
                    this.m_startTime = (this.m_startTime - ((_arg3) ? _arg3.specifiedValue() : 0));
                };
            };
        }
        public function get startTime():int{
            return (m_startTime);
        }
        public function get endValue():CSSProperty{
            return (m_endValue);
        }
        public function set startTime(_arg1:int):void{
            m_startTime = (m_lastUpdateTime = _arg1);
        }
        public function set startValue(_arg1:CSSProperty):void{
            m_startValue = _arg1;
            currentValue = CSSProperty(_arg1.clone(true));
            m_backupValue = CSSProperty(_arg1.clone(true));
            if (m_endValue){
                currentValue.setIsWeak(m_endValue.isWeak());
                m_backupValue.setIsWeak(m_endValue.isWeak());
            };
            m_propertyTransition.startValue = _arg1.specifiedValue();
            m_propertyTransition.currentValue = currentValue.specifiedValue();
        }
        public function set endValue(_arg1:CSSProperty):void{
            m_endValue = _arg1;
            if (currentValue){
                currentValue.setIsWeak(m_endValue.isWeak());
                m_backupValue.setIsWeak(m_endValue.isWeak());
            };
            m_propertyTransition.endValue = _arg1.specifiedValue();
        }
        public function get startValue():CSSProperty{
            return (m_startValue);
        }

    }
}//package reprise.css.transitions 
